﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Data.OleDb;
using DTO;
using BUS;

namespace GUI
{
    public partial class frmLoaiSach : Form
    {
        public frmLoaiSach()
        {
            InitializeComponent();
        }
        NguoiDungDTO nd;
        public void setNguoiDung(NguoiDungDTO ndung)
        {
            this.nd = ndung;
        }
        DataTable table;
        public void loadLoaiSach()
        {
            lvLoaiSach.Items.Clear();
            table = LoaiSachBUS.layFullLoaiSach();
            for (int i = 0; i < table.Rows.Count; i++)
            {

                ListViewItem item;
                string id = (i + 1).ToString();
                string name1 = table.Rows[i][1].ToString();
                string name2 = table.Rows[i][2].ToString();
                string name3 = table.Rows[i][3].ToString();
                string name4 = table.Rows[i][5].ToString();
                string name5 = table.Rows[i][4].ToString();
                item = new ListViewItem(id);
                item.SubItems.Add(name1);
                item.SubItems.Add(name2);
                item.SubItems.Add(name3);
                item.SubItems.Add(name4);
                item.SubItems.Add(name5);
                lvLoaiSach.Items.Add(item);
            }
        }
        private void frmLoaiSach_Load(object sender, EventArgs e)
        {
            loadLoaiSach();
        }

        private void lvLoaiSach_SelectedIndexChanged(object sender, EventArgs e)
        {
            foreach (ListViewItem lvItem in lvLoaiSach.SelectedItems)
            {
                txtTenLoaiSach.Text = lvItem.SubItems[1].Text;
                txtTienTo.Text = lvItem.SubItems[2].Text;
                txtMaSachNew.Text = lvItem.SubItems[3].Text;
                txtThueVAT.Text = lvItem.SubItems[4].Text;
                txtChiTiet.Text = lvItem.SubItems[5].Text;
            }
        }

        private void btnSua_Click(object sender, EventArgs e)
        {
            txtTenLoaiSach.Text = "";
            txtTienTo.Text = "";
            txtMaSachNew.Text = "";
            txtThueVAT.Text = "";
            txtChiTiet.Text = "";
        }

        private void btnReset_Click(object sender, EventArgs e)
        {
            txtTenLoaiSach.Text = "";
            txtTienTo.Text = "";
            txtMaSachNew.Text = "";
            txtThueVAT.Text = "";
            txtChiTiet.Text = "";
        }

    }
}
